import javax.swing.tree.TreeNode;
import java.util.LinkedList;
import java.util.Queue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-21
 * Time: 9:52
 */
public class Test{
    public boolean fun(TreeNode root){
        if(root==null){
            return true;
        }
        Queue<TreeNode> queue=new LinkedList<>();
        queue.offer(root);
        while(!queue.isEmpty()){
            TreeNode cur=queue.poll();
            if(cur==null){
                while(!queue.isEmpty()){
                    TreeNode cur2=queue.poll();
                    if(cur2!=null){
                        return false;
                    }
                }
            }
            queue.offer(root.left);
            queue.offer(root.right);
        }
        return true;
    }
    public static void main(String[] args) {

    }
}
